import React from "react";
import context from "./context";

const { Consumer } = context;

const Child2 = () => {
  return (
    <>
      <div>child2组件</div>
      {/* Consumer要写在需要用到参数的地方 */}
      {/* Consumer里面要写的是一个函数, 函数可以接受一个参数是value, 需要返回jsx */}
      <Consumer>
        {(value) => {
          console.log(value);
          return (
            <div>
              {value.count} - {value.msg}
            </div>
          );
        }}
      </Consumer>
    </>
  );
};

export default Child2;
